home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
strlib.zip
/
STRNLEN.C
< prev
next >
Wrap
Text File
|
1993-01-04
|
768b
|
40 lines
/* File : strnlen.c
Author : Richard A. O'Keefe.
Updated: 10 April 1984
Defines: strnlen()
strnlen(src, len)
returns the number of characters up to the first NUL in src, or len,
whichever is smaller. This is the same as strnend(src,len)-src.
Beware: the VaxAsm version only works for 0 <= len < 65535.
*/
#include "strings.h"
#if VaxAsm
int strnlen(src, len)
char *src;
int len;
{
asm("locc $0,8(ap),*4(ap)");
asm("subl3 4(ap),r1,r0");
}
#else ~VaxAsm
int strnlen(s, n)
register char *s;
register int n;
{
register int L;
for (L = 0; --n >= 0 && *s++; L++) ;
return L;
}
#endif VaxAsm